package cn.webrx.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import javax.sql.DataSource;

@Configuration
@PropertySource("classpath:db.properties")
public class DruidConfig {

    @Value("${db.url}")
    private String url;

    @Value("${db.username}")
    private String username;

    @Bean("ds")
    public DataSource dateSource(){
        var ds = new DruidDataSource();
        ds.setUrl(url);
        ds.setUsername(username);
        return ds;
    }
}
